package com.study.springsecurity.service.impl;

import com.study.springsecurity.dao.UserDao;
//import com.study.springsecurity.security.user.MyUserDetail;
import com.study.springsecurity.service.UserService;
import org.springframework.stereotype.Service;

/**
 * @Author: zzy
 * @Date: 2024/10/12 15:20
 * @Title:
 * @Version:
 * @Package: com.study.springsecurity.service.impl
 */
@Service
public class UserServiceImpl implements UserService {

    UserDao userDao;
//    @Resource
//    AuthenticationManager authenticationManager;

    public UserServiceImpl(UserDao userDao) {
        this.userDao = userDao;
    }


    @Override
    public String login(String username, String password) {

//
//        UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
//
//        Authentication authenticate = authenticationManager.authenticate(authenticationToken);
//
//        SecurityContextHolder.getContext().setAuthentication(authenticate);
//        if(Objects.isNull(authenticate)){
//            throw new RuntimeException("用户名或密码错误");
//        }
//        //使用userid生成token
//        MyUserDetail myUserDetail = (MyUserDetail) authenticate.getPrincipal();
//        String jwt = JwtUtil.createJWT(myUserDetail);
//
//        System.out.println(jwt);
////        //authenticate存入redis
////        redisCache.setCacheObject("login:"+userId,loginUser);
//        //把token响应给前端
//        return jwt;

        return "2";
    }
}
